""" 2_2 控制WS2812B单颗颜色变换 """
# https://learn.adafruit.com/adafruit-esp32-s3-tft-feather/neopixel-led

import time
import board
import neopixel
import digitalio
from rainbowio import colorwheel

# WS2812B 电源控制
power = digitalio.DigitalInOut(board.NEOPIXEL_POWER)
power.direction = digitalio.Direction.OUTPUT
power.value = True

# WS2812B设置
pixel = neopixel.NeoPixel(board.NEOPIXEL, 1)
# 亮度
pixel.brightness = 0.5

# 颜色变换
def rainbow(delay):
    for color_value in range(255):
        pixel[0] = colorwheel(color_value)
        time.sleep(delay)

while True:
    rainbow(0.02)